const db = uniCloud.database();
const userInfo = require('./user-info');
const { userLoginSendMessage } = require('../push/index.js');
module.exports = async function(options = {}) {
	const token = this.getUniIdToken();
	const { clientIP } = this.getClientInfo();
	const user_info = await userInfo({ token, clientIP });
	if (user_info.code == 0) {
		userLoginSendMessage(user_info.data);
		return {
			code: 0,
			data: {
				mobile: user_info.data.mobile ? user_info.data.mobile : '',
				member_type: user_info.data.member_type,
				member_time: user_info.data.member_time,
				ipaddress: user_info.data.ipaddress,
				maxCharacterCount: user_info.data.member_time > 0 ? 5 : 2
			},
			msg: '获取成功'
		}
	} else {
		return user_info;
	}
}